<?php
  mb_internal_encoding('utf-8');
  require "./class_suffixarray.php";
  require "./karkkainen_sanders.php";

  


  $str1 = "abcabc";
//  $str2 = "éécbacba";

  $factory_rstr = new suffixarray();
  $factory_rstr->__add_str($str1);
//  $factory_rstr->__add_str($str2);
  $res = $factory_rstr->__init();

  foreach($factory_rstr->__get_array_str() as $i=>$global_str){
    echo "string $i: $global_str\n";
  }

  foreach($res as $rstr){
    $first_suffix = $factory_rstr->__get_suffix($rstr[1][0]);
    $global_str = $factory_rstr->__get_str($first_suffix[2]);
    $str = mb_substr($global_str,$first_suffix[0],$rstr[0]);

    echo "maximal repeat : $str\n";
    
    foreach($rstr[1] as $id_su){
      $suffix = $factory_rstr->__get_suffix($id_su);
      $str_correspondante  = $factory_rstr->__get_str($suffix[2]);
      echo "  string $suffix[2] - offset $suffix[0] - length $rstr[0]\n";
    }

  }

?>
